package com.humble.vichatbackend.service.impl;

import org.springframework.data.domain.Page;
import com.humble.vichatbackend.common.SearchRequest;
import com.humble.vichatbackend.config.datasource.DataSource;
import com.humble.vichatbackend.config.datasource.DataSourceManager;
import com.humble.vichatbackend.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SearchServiceImpl implements SearchService {
    @Autowired
    DataSourceManager dataSourceManager;
    @Override
    public Page searchGather(SearchRequest searchRequest) {
        String type = searchRequest.getType();
        String context = searchRequest.getContext();
        int pageSize = searchRequest.getPageSize();
        int pageNum = searchRequest.getPageNum();
        DataSource dataSource = dataSourceManager.getDataSource(type);
        return dataSource.doSearch(searchRequest);

    }
}
